function isNumber(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}

function ktdiem($diem, $dong, $type){
	if(typeof($type)==='undefined') $type="";
	$ediem = "diem"+$type+$dong;
	$ediemcu = "diemcu"+$type+$dong;
	$edieman = "dieman"+$type+$dong;
	$eloi = "loi"+$dong;
	
    $diemcu=document.getElementById($edieman).value;
	$diemmax = 5;
	if($type=="") {$diemmax = 10;}
	$loidong = "loi"+$dong;
	
	if(isNumber($diem)){
       if($diem>=0 && $diem<=$diemmax){
        document.getElementById($ediemcu).style.color="red";
        document.getElementById($ediemcu).innerHTML=$diemcu;
       }else{
        document.getElementById($ediem).value=$diemcu;
		document.getElementById($eloi).style.color="red";
		document.getElementById($eloi).innerHTML="Điểm phải trong khoảng 0-"+$diemmax;	
		document.getElementById($ediemcu).innerHTML="";		
		setTimeout("document.getElementById($loidong).innerHTML=''",3000);
       }
	   if($diem == $diemcu){
	   document.getElementById($ediemcu).innerHTML="";
	   }
	} else {
	document.getElementById($eloi).innerHTML="Điểm phải là số";
	document.getElementById($eloi).style.color="red";
	setTimeout("document.getElementById($loidong).innerHTML=''",3000);
	document.getElementById($ediem).value=$diemcu;
	document.getElementById($ediemcu).innerHTML="";
	}
}

function diemthi($diem,$dong){
	ktdiem($diem,$dong);
}
